package com.sky.mapper;

import com.sky.dto.DishPageQueryDTO;
import com.sky.entity.Dish;
import com.sky.vo.DishVO;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface DishMapper {
    List<DishVO> selectPage(DishPageQueryDTO dishPageQueryDTO);
    @Update("update dish set status=#{status} where id =#{id}")
    void startOrStop(Integer status, Long id);

    void batchdelete(List<Integer> ids);
    @Select("select *from dish where id=#{id}")
    DishVO selectById(Long id);

    void updateDish(Dish dish);
    @Options(useGeneratedKeys = true,keyProperty = "id")
    @Insert("insert into dish(name, category_id, price, image, description, create_time, update_time, create_user, update_user) values" +
            "(#{name},#{categoryId},#{price},#{image},#{description},#{createTime},#{updateTime},#{createUser},#{updateUser}) ")
    void saveDish(Dish dish);
    @Select("select *from dish where category_id=#{categoryId}")
    List<DishVO> selectByCategoryId(Integer categoryId);
    @Select("select status from dish where id =#{id}")
    int selectStatusById(Integer id);
}
